package com.gl.servlet.action;

import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;

public class UpdateServlet extends HttpServlet {
	static Logger logger = Logger.getLogger(UpdateServlet.class);

	protected void service(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		try {
			ServletInputStream sis = req.getInputStream();
			int length = req.getContentLength();
			if (length > 0) {
				byte[] bInput = new byte[length];
				sis.read(bInput);
				String lwId = new String(bInput);
				logger.debug("要同步的受控词的ID为" + lwId);
				String responseXml = "华数接口同步受控词成功";
				byte[] bOutput = responseXml.getBytes();
				OutputStream os = res.getOutputStream();
				os.write(bOutput);
				os.flush();
				os.close();
				os = null;
				logger.debug("******华数接口同步受控词成功******");
			} else {
				logger.debug("-----华数接口同步受控词(失败)-----");
			}
		} catch (Exception e) {
			logger.error("", e);
		}
	}
}